import { Injectable } from '@angular/core';
import { IMyDpOptions } from 'mydatepicker';

@Injectable()
export class DateOptionService {
  public options: IMyDpOptions;
  constructor() { }
  setOption(timeType: string): IMyDpOptions {
    switch ( timeType ) {
      case 'day': {
        this.options = {
          dateFormat: 'yyyy-mm-dd',
          showTodayBtn: true,
          sunHighlight: true,
          disableSince: {year: 2020, month: 6, day: 26},
          disableUntil: {year: 2016, month: 6, day: 26}
        }
      } break;
      case 'month': {
        this.options = {
          dateFormat: 'yyyy-mm',
          showTodayBtn: true,
          sunHighlight: true,
          disableSince: {year: 2020, month: 6, day: 26},
          disableUntil: {year: 2016, month: 6, day: 26}
        }
      } break;
      case 'year': {
        this.options = {
          dateFormat: 'yyyy',
          showTodayBtn: true,
          sunHighlight: true,
          disableSince: {year: 2020, month: 6, day: 26},
          disableUntil: {year: 2016, month: 6, day: 26}
        }
      } break;
    };
    return this.options;
  }
  getOptions(): IMyDpOptions {
    return  this.options = {
      dateFormat: 'yyyy-mm-dd',
      showTodayBtn: true,
      sunHighlight: true,
      disableSince: {year: 2020, month: 6, day: 26},
      disableUntil: {year: 2016, month: 6, day: 26}
    }
  }
  getTimeOptions() {
    const timeOption = {
      minuteStep: 15,
      showMeridian: false,
      placeholder: '时:分   hh:mm'
    }
    return timeOption;
  }
}

